package cn.leyaber.hrm.redusutils;


import cn.leyaber.hrm.domain.Wholename;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;

public class UserContext {
    public static Wholename getWholename(HttpServletRequest request){
        String header = request.getHeader("U-TOKEN");
        if (StringUtils.isBlank(header)){
            //就和原来登录拦截失败返回结果一样
            return null;
        }

        String userJson = RedisUtils.INSTANCE.get(header);
        if (StringUtils.isBlank(userJson)){
            //就和原来登录拦截失败返回结果一样
            return null;
        }
        Wholename  wholename = JSONObject.parseObject(userJson, Wholename.class);
        return wholename;
    }
}
